﻿<html>
<head>
<link href="css/qam.css" rel="stylesheet" media="screen" />
<style>
#group_box{display:inline-block;}
</style>
</head>
<body>

	<div style="width:960px;margin:0 auto">
		<div id="message" ></div>
		
		<HR><h3>系统设置</h3>
		<div style="padding:10px;background:#E8E8FF;margin-top:10px;">
			<form method="post" action="#" name="myform" class="myform">
				<input type="hidden" value="" name="id" />
				<label><span>SVN 路径：</span><input type="text" value="" name="svn_path" /></label><BR />
				<label><span>SVN 用户名：</span><input type="text" value="" name="svn_username" /></label><BR />
				<label><span>SVN 密码：</span><input type="text" value="" name="svn_password" /></label><BR>
				<input type="button" value="SVN测试" onclick="svn_test();" name="button"  /><span id="svn_message"></span><BR>
				<label><span>框架关键字</span><input type="text" value="" name="refer_frame" /></label><BR />
				<label><span>模块关键字</span><input type="text" value="" name="refer_module" /></label><BR />
				<label><span>组件关键字</span><input type="text" value="" name="refer_component" /></label><BR />
				<hr>
				<label><span>模板</span><input type="hidden" value="" name="public_templet" />
				<a href="#" onclick="read('templet')">查看</a>
				<input type="file" id="file" size="10" multiple="true" onchange="select_templet(this.files)" /><BR />
				<label><span>公用css</span><input type="hidden" value="" name="public_css" />
				<a href="#" onclick="read('css')">查看</a>
				<input type="file" id="file" size="10" multiple="true" onchange="select_css(this.files)" /><hR />
				<a href="#" onclick="read('css')">查看</a>
				<label><span>权限类别：</span><input type="text" value="" name="power_sort" /></label><BR />
				
				<input type="button" value="修改" onclick="update();" name="button"  />
			</form>
		</div>
	</div>



</body>

<script src="js/ajax.js" type="text/javascript"></script>
<script src="js/md5.js" type="text/javascript"></script>
<script src="js/function.js" type="text/javascript"></script>
<script>



function init(){edit()}

//html5 选择文件
function select_templet(myFiles) {
  for (var i = 0, f; f = myFiles[i]; i++) {
    var imageReader = new FileReader();
    imageReader.onload = (function(aFile) {
      return function(e) {
        document.myform.public_templet.value=e.target.result;
		//document.getElementById('src_present').value=$$("src_file").files[0].name;
      };
	  
    })(f);
    imageReader.readAsDataURL(f);
  }
}

function select_css(myFiles) {
  for (var i = 0, f; f = myFiles[i]; i++) {
    var imageReader = new FileReader();
    imageReader.onload = (function(aFile) {
      return function(e) {
        document.myform.public_css.value=e.target.result;
		//document.getElementById('src_present').value=$$("src_file").files[0].name;
      };
	  
    })(f);
    imageReader.readAsDataURL(f);
  }
}

/*****查看文件********/

function read(t){
	var _url=cgipath+"setting-read";
	var ajax_obj=new AJAX_OBJ(_url,function(xmlHttp){
		//$$("message").innerHTML=xmlHttp.responseText;return;
		eval("var ret_json="+xmlHttp.responseText);
		if(t=="templet"){
			document.write("<pre>"+htmlspecialchars(ret_json.content.templet)+"</pre>");
		}
		else if(t=="css"){
			document.write("<pre>"+htmlspecialchars(ret_json.content.css)+"</pre>");
		}
	},handle_error,5000);
	ajax_obj.postData();
}


/*****svn 测试********/
function svn_test(){
	var _url=cgipath+"setting-svnTest";
	var ajax_obj=new AJAX_OBJ(_url,handle_svn_test,handle_error,5000);
	ajax_obj.postData(formToString(document.myform));
}

function handle_svn_test(xmlHttp){
	$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	document.myform.svn_username.value=ret_json.record.svn_username;
	document.myform.svn_password.value=ret_json.record.svn_password;
	document.myform.svn_path.value=ret_json.record.svn_path;
	document.myform.refer_frame.value=ret_json.record.refer_frame;
	document.myform.refer_module.value=ret_json.record.refer_module;
	document.myform.refer_component.value=ret_json.record.refer_component;
}

/*****setting getinfo********/
function edit(){
	var _url=cgipath+"setting-getinfo";
	var ajax_obj=new AJAX_OBJ(_url,handle_edit,handle_error,5000);
	ajax_obj.postData();
}

function handle_edit(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	document.myform.svn_username.value=ret_json.record.svn_username;
	document.myform.svn_password.value=ret_json.record.svn_password;
	document.myform.svn_path.value=ret_json.record.svn_path;
	document.myform.refer_frame.value=ret_json.record.refer_frame;
	document.myform.refer_module.value=ret_json.record.refer_module;
	document.myform.refer_component.value=ret_json.record.refer_component;
	document.myform.power_sort.value=ret_json.record.power_sort;
}


/*****setting update********/
function update(){
	var _url=cgipath+"setting-update";
	var ajax_obj=new AJAX_OBJ(_url,handle_update,handle_error,5000);
	ajax_obj.postData(formToString(document.myform));
}

function handle_update(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
}

</script>
<script src="js/public.js" type="text/javascript"></script>


</html>